#ifndef LIGHTMAPS_H
#define LIGHTMAPS_H

#include "SlippyMap.h"
#include "Waypoint.h"
#include "WaypointParser.h"
#include <QHttp>
#include <QtXml/QXmlInputSource>
#include <QtXml/QXmlSimpleReader>

class LightMaps: public QWidget
{
    Q_OBJECT

private:
    SlippyMap *m_normalMap;
    SlippyMap *m_largeMap;
    bool pressed;
    bool snapped;
    bool trackMap;
    bool waypointMode;
    QPoint pressPos;
    QPoint dragPos;
    QLinkedList<Waypoint> points;
    QNetworkAccessManager m_manager;
    QTimer *timer;

public:
    LightMaps(QWidget *parent = 0);
    void setCenter(qreal lat, qreal lng);
    bool getTrackMap();

signals:
    void updateTrackButton();

private slots:
    void updateMap(const QRect &r);
    void toggleTrackMap();
    void waypointSlot();
    void handleNetworkData(QNetworkReply*);
    void getWaypointsFromServer();

protected:
    void resizeEvent(QResizeEvent *);
    void paintEvent(QPaintEvent *event);
    void drawWaypoints(QPainter *p);
    void mouseReleaseEvent(QMouseEvent *);
    void keyPressEvent(QKeyEvent *event);
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void sendPoint(const Waypoint& w);
    void addToList(const QLinkedList<Waypoint> &list);

};

#endif // LIGHTMAPS_H
